<?php
/**
 * 用户逻辑层
 *
 */
namespace App\Dao;

use App\Models\BaseModel;

class Test extends Common
{
    const model = 'App\Models\TestModel';

    //自定义 直接用laravel的方法 不用封装的东西
    public static function getListPage(){
        $model = new BaseModel(self::model);
        return $model->getInstance()->where([])->paginate(3);
    }


    //列表
    public static function getList(){
        $model = new BaseModel(self::model);
        return $model->getModelLists(
            [],
            ['*'],
            ['id' => 'asc']
        );
    }

    //详情
    public static function getDetail($id){
        $model = new BaseModel(self::model);
        return $model->getModelDetail(
            ['id' => $id]
        );
    }

    //添加数据
    public static function create(){
        $model = new BaseModel(self::model);
        return $model->createModel(
            [
                'name' => '1',
                'content' => '2'
            ]
        );
    }

    //修改数据
    public static function update($id){
        $model = new BaseModel(self::model);
        return $model->updateModel(
            ['id' => $id],
            [
                'name' => '111',
                'content' => '233'
            ]
        );
    }

    //删除数据
    public static function delete($id){
        $model = new BaseModel(self::model);
        return $model->deleteModel(
            ['id' =>$id]
        );
    }
}
